﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace NewsletterMailingService
{
    [ServiceContract(Namespace="http://www.laboratoire-microsoft.org/newsletter/newsletterMailingService")]
    interface InewsletterService
    {
        /// <summary>
        /// Envoie un mail
        /// </summary>
        /// <param name="destinataires">Guid: Id/token de l'utilisateur. string:adressse email</param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <returns>true si résussie, false si échec</returns>
        [OperationContract]
        bool SendMail(Dictionary<int,string> destinataires, string message, string title);
/*
        /// <summary>
        /// Permet de configurer le service pour utiliser un serveur smtp
        /// </summary>
        /// <param name="smtpAdress"></param>
        /// <param name="login"></param>
        /// <param name="password"></param>
        [OperationContract]
        void Configure(string smtpAdress, string login, string password, int port, string sender);
*/
        /// <summary>
        /// Renvoie des information sur l'état du service d'envoie de mails
        /// </summary>
        /// <returns>Struct Infos si le service envoie des mails ou null si il est inactif</returns>
        [OperationContract]
        Infos GetState();

        /// <summary>
        /// Renvoie des infos sur tous les envois
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<Infos> GetStatistics();

    }

    [DataContract]
    public class Infos
    {
        [DataMember]
        public DateTime StartingDateTime { get; set; }

        [DataMember]
        public DateTime EndingDate { get; set; }

        [DataMember]
        public int MailsSent { get; set; }

        [DataMember]
        public int TotalMailsToSend { get; set; }
    }
}
